#include "../Tools/GLHeaders.hpp"
#include "Obj1.hpp"
#include <cmath>

void Obj1::Draw(void){
	glPushAttrib(GL_COLOR_BUFFER_BIT|GL_CURRENT_BIT|GL_TEXTURE_BIT);	
	glDisable(GL_TEXTURE_2D); 
	if(activate)
		glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
	else
		glColor4f(0.0f, 1.0f, 0.0f, 1.0f);

	glCallList(list_id);
	glPopAttrib();
}

void Obj1::Activate(void){
	activate = true;
}

void Obj1::Desactivate(void){
	activate = false;
}

Obj1::Obj1(void){ 
	list_id = glGenLists(1); // create one DisplayList
	glNewList(list_id, GL_COMPILE);
	glLineWidth(2);
	glBegin(GL_LINES);
	glVertex3f( 0.0f, 0.0f, 0.0f);
	glVertex3f( 0.25f, 0.0f, 0.0f);
	glVertex3f( 0.25f,-0.5f, 0.0f);
	glVertex3f( 0.25f, 0.5f, 0.0f);	
	glVertex3f( 0.25f,-0.5f, 0.0f);
	glVertex3f( 4.0f,-0.5f, 0.0f);
	glVertex3f( 0.25f, 0.5f, 0.0f);
	glVertex3f( 4.0f, 0.5f, 0.0f);
	glEnd();
	glEndList();
}

Obj1::~Obj1(void){
	glDeleteLists(list_id,1);
}

